//
//  YZEHomeUtils.m
//  yilutongxing
//
//  Created by ios-21 on 17/4/8.
//  Copyright © 2017年 YZE. All rights reserved.
//

#import "YZEHomeUtils.h"
#import "YZEHomeModel.h"
#import "YZEArticleModel.h"


#define ArticleURL @"/api/articles/"

@implementation YZEHomeUtils
-(void)requestHomeDateWithDelegate:(id)delegate AndUrl:(NSString*)url requestTag:(int)requestTag Completion:(MyCallback)callback{
    [[YZENetwork sharedInstace] getRequestWithUrl:url parameters:nil delegate:delegate requestTag:requestTag successBlock:^(id responseObject) {
        NSMutableArray *array = [NSMutableArray array];
        array = [YZEHomeModel mj_objectArrayWithKeyValuesArrayAdd:responseObject[@"sticks"]];
        NSMutableArray *array2 = [NSMutableArray array];
        array2 = [YZEHomeModel mj_objectArrayWithKeyValuesArrayAdd:responseObject[@"articles"]];
        NSMutableDictionary *resultDic = [NSMutableDictionary dictionary];
        [resultDic setObject:array forKey:@"sticks"];
        [resultDic setObject:array2 forKey:@"articles"];
        callback(resultDic);
    }];
}

-(void)requestArticleDateWithDelegate:(id)delegate requestTag:(int)requestTag AndID:(NSString *)ID Completion:(MyCallback)callback{
    
    [[YZENetwork sharedInstace] getRequestWithUrl:[NSString stringWithFormat:@"%@%@",[BASE stringByAppendingString:ArticleURL], ID] parameters:nil delegate:delegate requestTag:(int)requestTag successBlock:^(id responseObject) {
        NSMutableDictionary *dic = [NSMutableDictionary dictionary];
        [dic setObject:[[YZEArticleModel mj_objectWithKeyValuesAdd:responseObject] mj_keyValuesAdd] forKey:@"centent"];        
        callback(dic);
    }];
}

@end
